<div id="all">
<table id="finalOrder">
	<tr>
		<th colspan="5">
			Фирма
		</th>
	</tr>


	<tr>
		<td>
			<?php
				echo $choosenCompany->getName();
			?>
		</td>
		<td colspan="2">
			<?php
				echo $choosenCompany->getAddress();
			?>
		</td>
		<td colspan="2"> МОЛ -
			<?php
				echo $choosenCompany->getRespOfficial();
			?>
		</td>
	</tr>
	<tr>
		<th colspan="5">
			Магазин
		</th>
	</tr>

	<tr>
		<td id="shopId" class="<?php echo $choosenShop->getId();?>">
			<?php
				echo $choosenShop->getName();
			?>
		</td>
		<td colspan="2">
			<?php
				echo $choosenShop->getAddress();
			?>
		</td>
		<td>
			<?php
				echo $choosenShop->getPhone();
			?>
		</td>
		<td>
			<?php
				echo $choosenShop->getDelivery();
			?>
		</td>
	</tr>
	<tr>
		<th colspan="5">
			Кошница
		</th>
	</tr>
	<?php
		foreach ($_SESSION["order"]->getStocks() as $stock){
			if ($stock->getPromoPrice() !=null){
				$price=$stock->getPromoPrice() ;
			} else {
				$price=$stock->getPrice();
			}
			echo "<tr>
					<td width='200'>
						".$stock->getName()."
					</td>
					<td >
						".$stock->getOrderQuantity()."
					</td>
					<td>
						".$stock->getQuantity()."
					</td>
					<td>
						";
			printf("%.2f лв.",$price);
			echo         "
					</td>
					<td>
						";
			printf("<h3> %.2f лв. </h3> ",$price*$stock->getOrderQuantity());
			echo        "
					</td>
				</tr>";
		}

	?>
	<tr >
		<td colspan='5' style='text-align: right; right;padding-top: 20px;padding-right: 10px' >
			<h2> Сума : <?php printf(" %.2f лв. ", $_SESSION["order"]->getSum()); ?> </h2><br/>
		</td>
	</tr>
	<tr id='buy'>
		<td colspan='5' style='text-align: right;padding-top: 20px;' >
			<input type='button' class='button' onclick="location.href='?page=userOrder'"  value=' Обратно '>


			<input type='button' class='button' id='order' value=' Поръчай '>
		</td>
	</tr>

</table>
</div>
<script>
	$('#order').click(function(){
		var id = $("#shopId").attr("class");
		$.get("cntrlr/finishOrder.php", { finish : true , shopId : id})
			.done(function(data) {
				$("#main_content").html(data);

			});
	});
</script>



